public class Test {

    public static int sum(int n) {
        if(n == 1) {
            return 1;
        }
        return n + sum(n - 1);
    }

    public static void main(String[] args) {
        System.out.println(sum(10));
    }
   public static void func20(int n){
       if(n <= 9){
           System.out.println(n % 10);
           return;
       }
       func20(n/10);
       System.out.println(n%10);
   }

    public static void main9(String[] args) {
        func20(1234);
    }
    public static int fac1(int n){
        if(n == 1){
            return 1;
        }
        int tmp = n * fac1(n - 1);
        return tmp;
    }

    public static void main7(String[] args) {
        System.out.println(fac1(5));
    }

    public static int sum(int a,int b) {
        return a+b;
    }
    public static double sum(double a,double b){
        return a+b;
    }
    public static int sum(int a,int b,int c){
        return a+b+c;
    }

    public static void main6(String[] args) {
        int a = 10;
        int b = 20;
        int ret = sum(a,b);

        System.out.println(ret);
        double d1 = 12.4;
        double d2 = 17.8;
        double ret2 = sum(d1,d2);
        System.out.println(ret2);
        System.out.println(sum(1,2,3));
    }
    public static void main5(String[] args) {
        int a = 10;
        int b = 20;
        print(a, b);
    }
    public static void print(int x, int y) {
        System.out.println("x = " + x + " y = " + y);
    }
        public static void main4(String[] args) {
            int a = 10;
            int b = 20;
            swap(a, b);
            System.out.println("main: a = " + a + " b = " + b);
        }
        public static void swap(int x, int y) {
            int tmp = x;
            x = y;
            y = tmp;
            System.out.println("swap: x = " + x + " y = " + y);
        }

    public static void main3(String[] args) {
        int flg = 0;
        for (int i = 1; i <= 5; i++) {
            flg += fac(i);
        }
        System.out.println(flg);
    }
    public static int fac(int n){
        System.out.println("计算i的阶乘 n=" +n);
        int num = 1;
        for (int j = 1; j <=n ; j++) {
             num *= j;
        }
        return num;
    }
    public static int add2(int x, int y) {
        System.out.println("调用方法中 x = " + x + " y = " + y);
        return x + y;
    }


    public static boolean isLeapYear(int year){
        // int year= 1900;
        if((0 == year % 4 && 0 != year %100) || 0 == year % 400 ){
           // System.out.println(year + "年是闰年");
            return true;
        }else{
           // System.out.println(year + "你不是闰年");
             return false;
        }
    }
    public static int add(int a,int b){
        return a+b;
    }
    public static void main2(String[] args) {
        int a = 10;
        int b = 20;
        int ret1 = add(1,2);
        System.out.println("使用返回值：" + ret1);
        int ret2 = add(a,b);
        System.out.println("使用返回值：" + ret2);
        int p = ret1*5;
        System.out.println(p);
    }
    public static void main1(String[] args) {
        boolean flg =  isLeapYear(2022);
       // System.out.println(flg);
    }
}
